<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <!-- Parent POM -->
    <parent>
        <groupId>org.gephi</groupId>
        <artifactId>gephi-parent</artifactId>
        <version>0.9.2-SNAPSHOT</version>
        <relativePath>../..</relativePath>
    </parent>

    <groupId>org.gephi</groupId>
    <artifactId>gephi</artifactId>
    <packaging>nbm-application</packaging>
    <version>0.9.2-SNAPSHOT</version>
    <name>gephi-app</name>
    
    <properties>
        <skipJarGoal>false</skipJarGoal>
        <skipCreateTargz>true</skipCreateTargz>
        <skipReplaceWindowsIcon>true</skipReplaceWindowsIcon>
        <skipCreateExe>true</skipCreateExe>
        <skipCreateDmg>true</skipCreateDmg>
    </properties>

    <!-- Dependencies -->
    <dependencies>
        <dependency>
            <groupId>org.netbeans.cluster</groupId>
            <artifactId>platform</artifactId>
            <type>pom</type>
            <exclusions>
                <exclusion>
                    <artifactId>org-jdesktop-layout</artifactId>
                    <groupId>org.netbeans.api</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>org-netbeans-api-search</artifactId>
                    <groupId>org.netbeans.api</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>org-netbeans-api-visual</artifactId>
                    <groupId>org.netbeans.api</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>org-netbeans-core-execution</artifactId>
                    <groupId>org.netbeans.modules</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>org-netbeans-core-netigso</artifactId>
                    <groupId>org.netbeans.api</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>org-netbeans-core-osgi</artifactId>
                    <groupId>org.netbeans.modules</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>org-netbeans-core-output2</artifactId>
                    <groupId>org.netbeans.modules</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>org-netbeans-libs-osgi</artifactId>
                    <groupId>org.netbeans.api</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>org-netbeans-libs-felix</artifactId>
                    <groupId>org.netbeans.modules</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>org-netbeans-libs-jsr223</artifactId>
                    <groupId>org.netbeans.api</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>org-netbeans-libs-testng</artifactId>
                    <groupId>org.netbeans.api</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>org-netbeans-libs-junit4</artifactId>
                    <groupId>org.netbeans.api</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>org-netbeans-modules-core-kit</artifactId>
                    <groupId>org.netbeans.modules</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>org-netbeans-modules-netbinox</artifactId>
                    <groupId>org.netbeans.api</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>org-openide-compat</artifactId>
                    <groupId>org.netbeans.api</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>org-openide-options</artifactId>
                    <groupId>org.netbeans.api</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>org-openide-util-enumerations</artifactId>
                    <groupId>org.netbeans.api</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>org-netbeans-modules-editor-mimelookup-impl</artifactId>
                    <groupId>org.netbeans.modules</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>org-netbeans-modules-print</artifactId>
                    <groupId>org.netbeans.api</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>org-netbeans-modules-favorites</artifactId>
                    <groupId>org.netbeans.modules</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>org-netbeans-modules-javahelp</artifactId>
                    <groupId>org.netbeans.api</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>org-netbeans-modules-sampler</artifactId>
                    <groupId>org.netbeans.api</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>org-netbeans-modules-spi-actions</artifactId>
                    <groupId>org.netbeans.modules</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>org-netbeans-modules-junitlib</artifactId>
                    <groupId>org.netbeans.modules</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>org-netbeans-api-htmlui</artifactId>
                    <groupId>org.netbeans.api</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>org-netbeans-modules-templatesui</artifactId>
                    <groupId>org.netbeans.modules</groupId>
                </exclusion>
                <exclusion>
                    <groupId>org.netbeans.external</groupId>
                    <artifactId>net-java-html</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.netbeans.external</groupId>
                    <artifactId>net-java-html-boot</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.netbeans.external</groupId>
                    <artifactId>net-java-html-boot-fx</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.netbeans.external</groupId>
                    <artifactId>net-java-html-boot-script</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.netbeans.external</groupId>
                    <artifactId>net-java-html-geo</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.netbeans.external</groupId>
                    <artifactId>net-java-html-json</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.netbeans.external</groupId>
                    <artifactId>net-java-html-sound</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.netbeans.external</groupId>
                    <artifactId>org-netbeans-html-ko4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.netbeans.api</groupId>
                    <artifactId>org-netbeans-spi-quicksearch</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.netbeans.external</groupId>
                    <artifactId>org-netbeans-html-xhr4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.netbeans.api</groupId>
                    <artifactId>org-netbeans-modules-editor-mimelookup</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>gephi-branding</artifactId>
        </dependency>
        <dependency>
            <groupId>org.netbeans.api</groupId>
            <artifactId>org-netbeans-modules-nbjunit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>utils-longtask</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>project-api</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>graph-api</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>io-exporter-api</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>preview-api</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>io-exporter-preview</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>lib.validation</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>preview-export-ui</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>utils</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>datalab-api</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>visualization-api</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>preview-plugin</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>db-drivers</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>io-importer-api</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>io-processor-plugin</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>processor-plugin-ui</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>project-ui</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>ui-utils</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>ui-components</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>settings-upgrader</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>statistics-api</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>statistics-plugin</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>statistics-plugin-ui</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>timeline-api</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>tools-api</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>algorithms-plugin</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>gleem</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>mostrecentfiles-api</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>desktop-project</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>visualization</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>tools-plugin</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>welcome-screen</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>desktop-context</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>desktop-progress</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>desktop-branding</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>layout-api</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>io-generator-api</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>io-generator-plugin</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>generator-plugin-ui</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>io-exporter-plugin</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>desktop-statistics</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>filters-api</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>ui-propertyeditor</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>layout-plugin</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>desktop-generate</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>desktop-datalab</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>appearance-api</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>desktop-appearance</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>io-importer-plugin</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>filters-plugin</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>filters-impl</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>export-plugin-ui</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>desktop-recent-files</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>desktop-io-export</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>perspective-api</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>import-plugin-ui</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>desktop-banner</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>datalab-plugin</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>filters-plugin-ui</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>desktop-layout</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>desktop-import</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>desktop-preview</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>appearance-plugin</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>appearance-plugin-ui</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>desktop-tools</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>desktop-timeline</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>directory-chooser</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>desktop-filters</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>core-library-wrapper</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>ui-library-wrapper</artifactId>
        </dependency>
    </dependencies>
    
    <build>
        <plugins>
            <!-- Build jar only when not in deployment mode so install does not fail due to no attached artifacts -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration combine.self="override"> <!-- Override for not using the archive - manifestFile from parent pom -->
                    <skip>${skipJarGoal}</skip>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Disable the ZIP goal. Also set up the location of the gephi.conf -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>nbm-maven-plugin</artifactId>
                <configuration>
                    <!-- Set up the gephi.conf for the final artifact -->
                    <etcConfFile>${basedir}/target/${brandingToken}.conf</etcConfFile>
                </configuration>
                <executions>
                    <execution>
                        <id>default-standalone-zip</id>
                        <phase>none</phase>
                    </execution>
                </executions>
            </plugin>

            <!-- Do not generate a source jar -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <configuration>
                    <skipSource>true</skipSource>
                </configuration>
            </plugin>

            <!-- Copy ressources gephi.conf and Info.plist with filtering (replacing 'project.version' by the actual version -->
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>generate-app-conf-file</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/target/</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/resources</directory>
                                    <includes>
                                        <include>${brandingToken}.conf</include>
                                        <include>Info.plist</include>
                                    </includes>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                            <escapeString>\</escapeString>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <!-- The deployment profile is built for daily releases. It builds the standalone
        zip and the autoupdate site. It can be used with deploy-dmg to include the dmg as well. -->
        <profile>
            <id>deployment</id>
            <properties>
                <skipJarGoal>true</skipJarGoal>
            </properties>

            <!-- Localization dependency -->
            <dependencies>
                <dependency>
                    <groupId>nl.cloudfarming.client</groupId>
                    <artifactId>lib-platform-l10n</artifactId>
                    <version>${gephi.platform.localization.version}</version>
                </dependency>
            </dependencies>

            <build>
                <plugins>
                    <!-- Enable artifact deploy -->
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <configuration>
                            <skipNexusStagingDeployMojo>false</skipNexusStagingDeployMojo>
                        </configuration>
                    </plugin>

                    <!-- Permits NbModuleSuite to be run in integration-test phase: -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <systemPropertyVariables>
                                <all.clusters>${all.clusters}</all.clusters>
                                <branding.token>${brandingToken}</branding.token>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>replace-windows-icon</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <skip>${skipReplaceWindowsIcon}</skip>
                                    <!-- Target that replaces the icon for the launcher exe with our own icon. -->
                                    <target name="replaceWindowsLauncherIcon" description="Replace the icon for the Windows launcher exe">
                                        <!-- Windows -->
                                        <echo message="Replacing icon of Windows launcher executable."/>
                                        <exec dir="src/main/app-resources" executable="ReplaceVistaIcon.exe" resolveexecutable="true" osfamily="windows">
                                            <arg line="${project.build.directory}/${brandingToken}/bin/${brandingToken}.exe gephi.ico 0"/>
                                        </exec>
                                        <exec dir="src/main/app-resources" executable="ReplaceVistaIcon.exe" resolveexecutable="true" osfamily="windows">
                                            <arg line="${project.build.directory}/${brandingToken}/bin/${brandingToken}.exe gephifile.ico 1"/>
                                        </exec>
                                        <exec dir="src/main/app-resources" executable="ReplaceVistaIcon.exe" resolveexecutable="true" osfamily="windows">
                                            <arg line="${project.build.directory}/${brandingToken}/bin/${brandingToken}64.exe gephi.ico 0"/>
                                        </exec>
                                        <exec dir="src/main/app-resources" executable="ReplaceVistaIcon.exe" resolveexecutable="true" osfamily="windows">
                                            <arg line="${project.build.directory}/${brandingToken}/bin/${brandingToken}64.exe gephifile.ico 1"/>
                                        </exec>

                                        <!-- Linux (assuming the right wine configuration) -->
                                        <echo message="Replacing icon of Windows launcher executable."/>
                                        <exec dir="src/main/app-resources" executable="replacevistaicon" os="Linux">
                                            <arg line="${project.build.directory}/${brandingToken}/bin/${brandingToken}.exe gephi.ico 0"/>
                                        </exec>
                                        <exec dir="src/main/app-resources" executable="replacevistaicon" os="Linux">
                                            <arg line="${project.build.directory}/${brandingToken}/bin/${brandingToken}.exe gephifile.ico 1"/>
                                        </exec>
                                        <exec dir="src/main/app-resources" executable="replacevistaicon" os="Linux">
                                            <arg line="${project.build.directory}/${brandingToken}/bin/${brandingToken}64.exe gephi.ico 0"/>
                                        </exec>
                                        <exec dir="src/main/app-resources" executable="replacevistaicon" os="Linux">
                                            <arg line="${project.build.directory}/${brandingToken}/bin/${brandingToken}64.exe gephifile.ico 1"/>
                                        </exec>
                                    </target>
                                </configuration>
                            </execution>
                            
                            <!-- Execute InnoSetup with the gephi.iss script -->
                            <execution>
                                <id>create-windows-installer</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <skip>${skipCreateExe}</skip>
                                    <target name="createInstaller" description="Create Windows installer with InnoSetup">
                                        <echo message="Creating windows installer with InnoSetup"/>
                                        <delete file="${project.artifactId}-${project.version}.setup.exe" failonerror="false"/>

                                        <!-- Windows -->
                                        <exec dir="${project.build.directory}" executable="${gephi.innosetup.path}/Compil32.exe" osfamily="windows">
                                            <arg line="/cc &quot;${brandingToken}.iss&quot;" />
                                        </exec>

                                        <!-- Linux (assuming the right wine configuration) -->
                                        <exec dir="${project.build.directory}" executable="iscc" os="Linux">
                                            <arg line="${brandingToken}.iss" />
                                        </exec>
                                    </target>
                                </configuration>
                            </execution>
                            
                            <!-- Create the Mac OS X application bundle and dmg file -->
                            <execution>
                                <id>create-app-bundle</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <skip>${skipCreateDmg}</skip>
                                    <target>
                                        <!-- Clean -->
                                        <delete includeEmptyDirs="true" failonerror="false" removeNotFollowedSymlinks="true">
                                            <fileset dir="${project.build.directory}/${gephi.appbundle.name}.app" followsymlinks="false"/>
                                            <fileset dir="${project.build.directory}/${gephi.app.title}" followsymlinks="false"/>
                                            <fileset dir="${project.build.directory}/${project.artifactId}-${project.version}.dmg" followsymlinks="false"/>
                                        </delete>
                                        <delete file="${project.build.directory}/${project.artifactId}-${project.version}.dmg" failonerror="false"/>

                                        <!-- Create folders -->
                                        <mkdir dir="${project.build.directory}/${gephi.appbundle.name}.app"/>
                                        <mkdir dir="${project.build.directory}/${gephi.appbundle.name}.app/Contents/MacOS"/>

                                        <!-- Copy application -->
                                        <copy todir="${project.build.directory}/${gephi.appbundle.name}.app/Contents/Resources/${brandingToken}">
                                            <fileset dir="${project.build.directory}/${brandingToken}"/>
                                        </copy>

                                        <!-- Copy logo and configuration files -->
                                        <copy tofile="${project.build.directory}/${gephi.appbundle.name}.app/Contents/Resources/${brandingToken}.icns" file="src/main/app-resources/${brandingToken}.icns" />
                                        <copy tofile="${project.build.directory}/${gephi.appbundle.name}.app/Contents/Info.plist" file="${project.build.directory}/Info.plist"/>

                                        <!-- Move bin/gephi script into MacOS/gephi and modify the script so it founds its resources -->
                                        <move file="${project.build.directory}/${gephi.appbundle.name}.app/Contents/Resources/${brandingToken}/bin/${brandingToken}" todir="${project.build.directory}/${gephi.appbundle.name}.app/Contents/MacOS"/>
                                        <replace file="${project.build.directory}/${gephi.appbundle.name}.app/Contents/MacOS/${brandingToken}" token="`dirname &quot;$PRG&quot;`" value="`dirname &quot;$PRG&quot;`&quot;/../Resources/gephi/bin&quot;"/>
                                        <chmod file="${project.build.directory}/${gephi.appbundle.name}.app/Contents/MacOS/${brandingToken}" perm="ugo+rx"/>

                                        <!-- Download and untar JRE -->
                                        <exec dir="${project.build.directory}" executable="curl">
                                            <arg line="-L"/>
                                            <arg line="-C"/>
                                            <arg line="-"/>
                                            <arg line="-b"/>
                                            <arg line="&quot;oraclelicense=accept-securebackup-cookie&quot;"/>
                                            <arg line="-O"/>
                                            <arg line="${gephi.bundle.jre.url}/${gephi.bundle.jre.version}.tar.gz"/>
                                        </exec>

                                        <!-- Unzip archive -->
                                        <mkdir dir="${project.build.directory}/${gephi.appbundle.name}.app/Contents/PlugIns"/>
                                        <exec dir="${project.build.directory}" executable="tar">
                                            <arg line="-zxf"/>
                                            <arg line="${gephi.bundle.jre.version}.tar.gz"/>
                                            <arg line="-C ${gephi.appbundle.name}.app/Contents/PlugIns"/>
                                        </exec>

                                        <!-- Remove quarantine bit set recursively on JRE -->
                                        <exec dir="${project.build.directory}" os="Mac OS X" executable="xattr">
                                            <arg line="-rd"/>
                                            <arg line="com.apple.quarantine"/>
                                            <arg line="${gephi.appbundle.name}.app/Contents/PlugIns"/>
                                        </exec>

                                        <!-- Get the JRE folder name -->
                                        <path id="jre_name">
                                            <dirset dir="${project.build.directory}/${gephi.appbundle.name}.app/Contents/PlugIns" includes="jre*" />
                                        </path>
                                        <property name="bundle.jre.path" refid="jre_name" />
                                        <basename property="bundle.jre.name" file="${bundle.jre.path}"/>

                                        <!-- Configure relative JRE path into gephi.conf -->
                                        <replace file="${project.build.directory}/${gephi.appbundle.name}.app/Contents/Resources/${brandingToken}/etc/${brandingToken}.conf" token="#jdkhome=&quot;/path/to/jdk&quot;" value="jdkhome=&quot;../../PlugIns/${bundle.jre.name}/Contents/Home&quot;"/>
                                        <chmod file="${project.build.directory}/${gephi.appbundle.name}.app/Contents/PlugIns/**" perm="+x" type="both"/>

                                        <!-- Fix JRE by replacing libjli.dylib symlink with real file -->
                                        <delete file="${project.build.directory}/${gephi.appbundle.name}.app/Contents/PlugIns/${bundle.jre.name}/Contents/MacOS/libjli.dylib"/>
                                        <copy file="${project.build.directory}/${gephi.appbundle.name}.app/Contents/PlugIns/${bundle.jre.name}/Contents/Home/lib/jli/libjli.dylib" todir="${project.build.directory}/${gephi.appbundle.name}.app/Contents/PlugIns/${bundle.jre.name}/Contents/MacOS"/>

                                        <!-- Codesign JRE -->
                                        <exec dir="${project.build.directory}" os="Mac OS X" executable="codesign">
                                            <arg value="-fs"/>
                                            <arg value="${gephi.codesign.identity}"/>
                                            <arg value="-v"/>
                                            <arg value="${gephi.appbundle.name}.app/Contents/PlugIns/${bundle.jre.name}/"/>
                                        </exec>

                                        <!-- Codesign app -->
                                        <exec dir="${project.build.directory}" os="Mac OS X" executable="codesign">
                                            <arg value="-fs"/>
                                            <arg value="${gephi.codesign.identity}"/>
                                            <arg value="-v"/>
                                            <arg value="${gephi.appbundle.name}.app"/>
                                        </exec>

                                        <!-- Create application folder and add Applications dynamic link -->
                                        <mkdir dir="${project.build.directory}/${gephi.app.title}"/>
                                        <move file="${project.build.directory}/${gephi.appbundle.name}.app" todir="${project.build.directory}/${gephi.app.title}/" />
                                        <symlink link="${project.build.directory}/${gephi.app.title}/Applications" resource="/Applications" failonerror="false" />

                                        <!-- Create DMG (Mac OS X) -->
                                        <exec dir="${project.build.directory}" os="Mac OS X" executable="hdiutil">
                                            <arg value="create"/>
                                            <arg value="-noanyowners"/>
                                            <arg value="-imagekey"/>
                                            <arg value="zlib-level=9"/>
                                            <arg value="-srcfolder"/>
                                            <arg value="${project.build.directory}/${gephi.app.title}"/>
                                            <arg value="${project.artifactId}-${project.version}.dmg"/>
                                        </exec>

                                        <!-- Create DMG (Linux), only for testing -->
                                        <exec dir="${project.build.directory}" os="Linux" executable="genisoimage">
                                            <arg value="-V"/>
                                            <arg value="${gephi.appbundle.name}"/>
                                            <arg value="-U"/>
                                            <arg value="-D"/>
                                            <arg value="-l"/>
                                            <arg value="-allow-multidot"/>
                                            <arg value="-max-iso9660-filenames"/>
                                            <arg value="-relaxed-filenames"/>
                                            <arg value="-no-iso-translate"/>
                                            <arg value="-r"/>
                                            <arg value="-o"/>
                                            <arg value="${project.artifactId}-${project.version}.dmg"/>
                                            <arg value="-root"/>
                                            <arg value="${project.build.directory}/${gephi.app.title}"/>
                                            <arg value="${project.build.directory}/${gephi.app.title}"/>
                                        </exec>
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    
                    <!-- Assembler to produce linux's tar.gz -->
                    <plugin>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>linux-assembly</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>single</goal>
                                </goals>
                                <configuration>
                                    <skip>${skipCreateTargz}</skip>
                                    <tarLongFileMode>gnu</tarLongFileMode>
                                    <finalName>${brandingToken}-${project.version}</finalName>
                                    <descriptors>
                                        <descriptor>src/assemble/linux.xml</descriptor>
                                    </descriptors>
                                    <attach>false</attach>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <executions>
                            <!-- Attach tar.gz artifact -->
                            <execution>
                                <id>attach-linux</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>attach-artifact</goal>
                                </goals>
                                <configuration>
                                    <skipAttach>${skipCreateTargz}</skipAttach>
                                    <artifacts>
                                        <artifact>
                                            <file>${basedir}/target/${brandingToken}-${project.version}-linux.tar.gz</file>
                                            <type>tar.gz</type>
                                            <classifier>linux</classifier>
                                        </artifact>
                                    </artifacts>
                                </configuration>
                            </execution>
                            
                            <!-- Attach the final exe installer for deployment -->
                            <execution>
                                <id>attach-exe</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>attach-artifact</goal>
                                </goals>
                                <configuration>
                                    <skipAttach>${skipCreateExe}</skipAttach>
                                    <artifacts>
                                        <artifact>
                                            <file>${project.build.directory}/${project.artifactId}-${project.version}.setup.exe</file>
                                            <type>exe</type>
                                            <classifier>windows</classifier>
                                        </artifact>
                                    </artifacts>
                                </configuration>
                            </execution>
                            
                            <!-- Attach the final DMG for deployment -->
                            <execution>
                                <id>attach-dmg</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>attach-artifact</goal>
                                </goals>
                                <configuration>
                                    <skipAttach>${skipCreateDmg}</skipAttach>
                                    <artifacts>
                                        <artifact>
                                            <file>${project.build.directory}/${project.artifactId}-${project.version}.dmg</file>
                                            <type>dmg</type>
                                            <classifier>macos</classifier>
                                        </artifact>
                                    </artifacts>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- Profile used along with deployment to create the autoupdate site -->
        <profile>
            <id>create-autoupdate</id>
            <build>
                <plugins>
                    <!-- NBM Plugin settings. Enable the autoupdate generation -->
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>nbm-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>autoupdate</id>
                                <goals>
                                    <goal>autoupdate</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${project.build.directory}/site</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- Profile used along with deployment to create the sources artifact -->
        <profile>
            <id>create-sources</id>
            <build>
                <plugins>
                    <!-- Attach parent's sources artifact -->
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>attach-artifact</goal>
                                </goals>
                                <configuration>
                                    <artifacts>
                                        <artifact>
                                            <file>${basedir}/../../target/${brandingToken}-${project.version}-sources.tar.gz</file>
                                            <type>tar.gz</type>
                                            <classifier>sources</classifier>
                                        </artifact>
                                    </artifacts>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        
        <!-- Profile used along with deployment to create the tar.gz artifact -->
        <profile>
            <id>create-targz</id>
            <properties>
                <skipCreateTargz>false</skipCreateTargz>
            </properties>
        </profile>
        
        <!-- Profile used along with targz and windows exe to replace the windows icon -->
        <profile>
            <id>replace-windows-icon</id>
            <properties>
                <skipReplaceWindowsIcon>false</skipReplaceWindowsIcon>
            </properties>
        </profile>

        <!-- Profile activated for windows release in addition of deployement. Create the installer. -->
        <profile>
            <id>create-exe</id>
            <properties>
                <skipCreateExe>false</skipCreateExe>
            </properties>
            <build>
                <plugins>
                    <!-- Copy and filter the InnoSetup config file, as well as icons -->
                    <plugin>
                        <artifactId>maven-resources-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>generate-iss-file</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <escapeString>!!!</escapeString>
                                    <outputDirectory>${basedir}/target</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>src/main/app-resources</directory>
                                            <includes>
                                                <include>${brandingToken}.iss</include>
                                            </includes>
                                            <filtering>true</filtering>
                                        </resource>
                                        <resource>
                                            <directory>src/main/app-resources</directory>
                                            <includes>
                                                <include>${brandingToken}.ico</include>
                                                <include>${brandingToken}file128.png</include>
                                                <include>COPYING.txt</include>
                                            </includes>
                                            <filtering>false</filtering>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        
        <!-- Profile used along with deployment to create the dmg archive -->
        <profile>
            <id>create-dmg</id>
            <properties>
                <skipCreateDmg>false</skipCreateDmg>
            </properties>
        </profile>

        <!-- Profile that pushes the /site folder to GitHub's gh-pages -->
        <profile>
            <id>push-site</id>
            <build>
                <plugins>
                    <!-- Copy parent's site into target/site -->
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>site</phase>
                                <configuration>
                                    <target>
                                        <copy todir="${project.build.directory}/site">
                                            <fileset dir="${basedir}/../../target/site"/>
                                        </copy>
                                    </target>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- Publish site folder to GitHub's gh-pages branch -->
                    <plugin>
                        <groupId>com.github.github</groupId>
                        <artifactId>site-maven-plugin</artifactId>
                        <configuration>
                            <message>Creating site for ${project.version}</message>
                            <path>${project.version}</path>
                            <merge>true</merge>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>site</goal>
                                </goals>
                                <phase>site</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
